package interceptor;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

import common.Access;

public class AccessInterceptor implements Interceptor {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2578561479301489061L;

	public void destroy() {
	}


	public void init() {
		System.out.println("访问类型拦截器初始化");
	}

	public String intercept(ActionInvocation invocation) throws Exception {
		HttpServletRequest request = (HttpServletRequest) invocation.getInvocationContext().get(StrutsStatics.HTTP_REQUEST);
		invocation.getInvocationContext().getSession().put("access", Access.access(request));
		return invocation.invoke();
	}

}
